package com.lck.blogmanager.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lck.blogmanager.common.Response;
import com.lck.blogmanager.req.*;
import com.lck.blogmanager.res.UserBlogCommentPageRes;
import com.lck.blogmanager.res.UserQuestionCommentPageRes;
import com.lck.blogmanager.service.QuestionCommentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 问答评论
 * @author wyq
 * @version v1.0.0
 * @explain
 * @date 2024/4/7 18:29
 */
@CrossOrigin
@RequestMapping("/questionComment")
@RequiredArgsConstructor
@Slf4j
@RestController
public class QuestionCommentController {

    private final QuestionCommentService questionCommentService;

    /**
     * 问答添加评论
     * @param req
     * @return
     */
    @PostMapping("/add")
    public Response<Integer> addQuestionComment(@RequestBody AddQuestionCommentReq req){
        Integer commentId = questionCommentService.addQuestionComment(req);
        return Response.success(commentId);
    }

    /**
     * 问答查询评论
     * @return
     */
    @PostMapping("/pageComment")
    public Response<Page<UserQuestionCommentPageRes>> pageQuestionComment(@RequestBody PageQuestionCommentReq req){
        Page<UserQuestionCommentPageRes> res = questionCommentService.pageQuestionComment(req);
        return Response.success(res);
    }

    /**
     * 用户删除评论
     * @param req
     * @return
     */
    @PostMapping("/deleteComment")
    public Response deleteComment(@RequestBody UserDeleteQuestionCommentReq req){
        questionCommentService.deleteComment(req);
        return Response.success();
    }

}
